import Stats = require('stats.js');

export default class DebugInfo {
  public static _instance: DebugInfo = null;
  public static get Instance() {
    if (!this._instance) {
      this._instance = new DebugInfo();
    }
    return this._instance;
  }

  private _stats;

  public get stats() {
    return this._stats;
  }

  public begin() {
    this.stats.begin();
  }

  public end() {
    this.stats.end();
  }

  private constructor() {
    this._stats = new Stats();
    this.stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom
    const el = document.getElementById('debug-info');
    const container = this.stats.dom as HTMLElement;
    el.appendChild(container);
    container.style.position = 'relative';
  }
}
